package bookstudytest.threadtest.implement;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author heng.li
 */
public class ThreadByCallable implements Callable<String> {

    @Override
    public String call() throws Exception {
        return "hello callable";
    }

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ThreadByCallable threadByCallable = new ThreadByCallable();
        FutureTask future = new FutureTask(threadByCallable);
        Thread thread1 = new Thread(future);
        thread1.start();
        System.out.println(future.get());
    }
}
